<%DIRECTIVE DYNAMIC;%>
<div class="modal-header">
	<button type="button" class="close" data-dismiss="modal" aria-label="Close">
		<span aria-hidden="true">&times;</span>
	</button>
	<h5 class="modal-title" >修改</h5>
</div>

<form id="eidtForm" role="form" class="form-horizontal parsley-form" data-parsley-validate
                  action="${base}/platform/site/infomation/editDo" method="post">
                  <div class="modal-body ">
               	<input type="hidden" name="id" value="${obj.id!}">
               	<input type="hidden" name="createAt" value="${obj.createAt!}">
                <div class="row mb10">
                   <div class="col-lg-12">
                        <div class="form-group">
                            <label for="title" class="col-sm-2 control-label">标题</label>
                            <div class="col-sm-8">
                                <input type="text" id="title" class="form-control" name="title" required="required" placeholder="标题" value="${obj.title!}">
                            </div>
                        </div>
                   		<div class="form-group">
                        	<label for="img" class="col-sm-2 control-label">缩略图</label>

                            <div class="col-sm-8">
                            	<div id="img_queue"></div>
                                <div>
                                	<input id="img_file_upload"  type="file" multiple="false">
                                </div>
                                <div id="img_img" style="padding: 5px;">
                                	<%if(!isEmpty(obj.img)){%>
                                        <img src='${AppUploadRoot!}${obj.img!}' style='width:150px;'>
                                        <i class="fa fa-close" onclick="$('#img').val('');$('#img_img').html('');"></i>
                                   <%}%>
                                </div>
                                <input type="hidden" id="img" name="img" value="${obj.img!}" >
                           	</div>
                       	</div>
                        <div class="form-group">
                            <label for="link" class="col-sm-2 control-label">链接</label>
                            
                            <div class="col-sm-8">
                                <input type="text" id="link" class="form-control" name="link"  data-parsley-maxlength="255" placeholder="链接" value="${obj.link!}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="remark" class="col-sm-2 control-label">备注</label>

                            <div class="col-sm-8">
                                <textarea rows="5" cols="5" id="remark" class="form-control" name="remark" data-parsley-required="true" data-parsley-maxlength="5000"  placeholder="备注">${obj.remark!}</textarea>
                            </div>
                        </div>
                       	<div class="form-group">
		                 	<label for="createAt" class="col-sm-2 control-label">时间</label>
		               		<div class="col-sm-8">
			               		<input type="text" class="form-control" id="createAt" name="createAtStr" value="${@date.getDate(obj.createAt!)}" />
			              	</div>
		             	</div>
                    </div>
                </div>
                </div>
	<div class="modal-footer">
		<button  class="btn btn-default btn-sm btn-parsley"  >完成</button> 
	</div>
            </form>
<script language="JavaScript">
	function img_clearFile() {
	    $("#img_img").html("");
	    $("#img_queue").html("");
	    $("#img").val("");
	}
    $(document).ready(function () {
    	$('#img_file_upload').uploadifive({
            'auto': true,
            'multi': false,
            'width': '100%',
            'height': '35',
            'buttonText': '请选择图片',
            'fileType': 'image/*',
            'fileSizeLimit': 1024,
            'queueSizeLimit': 1,
            'formData': {},
            'queueID': 'img_queue',
            'uploadScript': '${base}/open/file/upload/image',
            'onUploadComplete': function (file, data) {
                data = JSON.parse(data);
                if (data.code == 0) {
                    Toast.success(data.msg);
                    $("#img_img").html("<img src='${AppUploadRoot}" + data.data + "' style='width:150px;height:95px;'>");
                    $("#img").val(data.data);
                } else {
                	img_clearFile();
                    Toast.error(data.msg);
                }
            },
            'onDrop': function (file, fileDropCount) {
            	img_clearFile();
            },
            'onClearQueue': function (queue) {
            	img_clearFile();
            },
            'onCancel': function () {
            	img_clearFile();
            }
        });
    	$.datetimepicker.setLocale('ch');
	   	$('#createAt').datetimepicker({
        	lang:'ch',
           	format:'Y-m-d H:i:s'
       	});
    	var dialog=$("#editModal");
		$("#editModalDialog").draggable();
        $('#eidtForm').ajaxForm({
            dataType: 'json',
            beforeSubmit: function (arr, form, options) {
            },
            success: function (data, statusText, xhr, form) {
                if (data.code == 0) {
                    Toast.success(data.msg);
                    datatable.ajax.reload();
	               	dialog.modal("hide");
                } else {
                    Toast.error(data.msg);
                    datatable.ajax.reload();
                 	dialog.modal("hide");
                }
            }
        });
    });
</script>
